'use strict';
$(function(){
getLessons();
});
function getLessons(){
      $.ajax({
        url:"publishlessons/hot",
        type:"GET",
      	contentType:"application/json",
        dataType:"json",
        success:function(data){
            if(data.rows.length>0) {
                //success
                fillHotLessons(data.rows);
            }
            else {
               layer.msg(langThis("kc_queryLessonFail"));
            }

        },
        error:function(event){
            layer.msg(langThis("kc_queryLessonFail"));

        }
    });

}

function fillHotLessons(lessons){
var ht='';
for(var i in lessons){
    var theLesson=lessons[i];
    var detail='lessonDetail?i='+theLesson.id+'&p='+theLesson.phase;
    ht+="<li class=\"media lessonbottomHr\"><a class=\"media-left\" href='"+detail+"'><img src=\""+theLesson.image+"\"  class=\"lessonimg\"></a><div class=\"media-body\"><h3 class=\"media-heading lessonTitle\">"+theLesson.name+"</h3><p class=\"lessontxt\">"+theLesson.description+"</p><a role=\"button\" class=\"btn lessonBtn\"  href=\""+detail+"\">"+langThis('ms_lessDetail')+"</a><span class=\"label label-danger typepahse\">"+langThis('cm_coursePhase').replace('{p}',theLesson.phase)+"</span><span class=\"label label-info typepahse\">"+ (/zh/.test(getCurrentLang()) ? theLesson.typenamecn : theLesson.typenameen)+"</span></div></li>";
}
$('#hotUl').html(ht);
}